<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>跨域请求之CORS</title>
</head>
<body>
    <h1>跨域请求之CORS</h1>
    
    <script>
        document.addEventListener('DOMContentLoaded',function(){
            let xhr = new XMLHttpRequest();
            xhr.onload = function(){
                console.log('data=',xhr.responseText);
            }
            xhr.open('post','http://localhost:2008/api/cors',true);
            xhr.setRequestHeader('Content-Type','application/x-www.form-urlencoded');
            xhr.send();
        })

    </script>
</body>
</html>